package com.egg.demo.controller.web;

import com.egg.common.core.model.controller.WebController;
import com.egg.common.core.model.response.ResponseData;
import com.egg.common.translate.util.I18nUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author east
 */
@Slf4j
@Api(tags = WebController.API_PREFIX + "i18n")
@RestController
@RequestMapping("/i18n")
public class WebI18nController extends WebController {


    @ApiOperation(value = "测试翻译")
    @GetMapping
    public ResponseData<String> translation(
            @ApiParam(value = "编码") @RequestParam(value = "code") String code
            , @ApiParam(value = "默认信息") @RequestParam(value = "def") String def
    ) {
        String message = I18nUtil.translation(code, def);
        return ResponseData.success(message);
    }


}
